﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Utilities.QuickSql;
using MySql.Data;

namespace Deviseur_Cs2i_Car
{
    class OPTION
    {

        int NumOption;
        string NomOption;
        double PrixOption;

        CATEGOPTION CategOption = new CATEGOPTION();
        List<SSOPTION> TabSSOption = new List<SSOPTION>();

        public OPTION() { }

        public OPTION(int NumOption)
        {
            this.NumOption = NumOption;
        }
        public OPTION(string NomOption,double PrixOption,int categ)
        {
            this.NomOption = NomOption;
            this.PrixOption = PrixOption;
            this.CategOption.set_NumCategOption(categ);
        }
        public OPTION(int NumOption, string NomOption, double PrixOption, int categ)
        {
            this.NumOption = NumOption;
            this.NomOption = NomOption;
            this.PrixOption = PrixOption;
            this.CategOption.set_NumCategOption(categ);
        }


        public int get_NumOption()
        {
            return this.NumOption;
        }
        public string get_NomOption()
        {
            return this.NomOption;
        }
        public double get_PrixOption()
        {
            return this.PrixOption;
        }

        public CATEGOPTION get_CategOption()
        {
            return this.CategOption;
        }
        public SSOPTION get_SSOption(int i)
        {
            return this.TabSSOption[i];
        }


        public void set_CategOption(CATEGOPTION categ)
        {
            this.CategOption = categ;
        }
        public void set_SSOption(SSOPTION ssoption, int i)
        {
            this.TabSSOption[i] = ssoption;
        }

        public void set_NumOption(int NumOption)
        {
            this.NumOption = NumOption;
        }
        public void set_NomOption(string NomOption)
        {
            this.NomOption = NomOption;
        }
        public void set_PrixOption(double PrixOption)
        {
            this.PrixOption = PrixOption;
        }
        public void set_LibelleOption(string LibelleOption)
        {
            this.NomOption = LibelleOption;
        }
        public void affiche_Option()
        {
            Console.WriteLine("Num  option : ", this.NumOption);
            Console.WriteLine("Nom  option : ", this.NomOption);
            Console.WriteLine("prix  option: ", this.PrixOption);
            Console.WriteLine("categoption categ : ", this.CategOption);
        }
        public void new_Option()
        {
            Program.Db.Execute("INSERT INTO OPTIONS(LibelleOption,PrixOption,NumCateg) VALUES ('" + this.NomOption + "', '" + this.PrixOption + "', '" + this.CategOption.get_NumCategOption() + "')");
        }
        public void modify_Option()
        {
            Program.Db.Execute("UPDATE OPTIONS SET LibelleOption = '" + this.NomOption + "', PrixOption = '" + this.PrixOption + "', NumCateg = " + this.CategOption.get_NumCategOption() + " WHERE NumOption = " + this.NumOption + "");
        }
        public void delete_Option(int NumOption)
        {
            Program.Db.Execute("DELETE FROM OPTIONS WHERE NumOption = " + NumOption + "");
        }

    }
}

